package android.slc.user.ui.dept.delegate

import android.slc.extras.user.entity.SysDept
import android.slc.user.ui.dept.adapter.DeptSingleAdapter
import android.slc.user.ui.dept.vmbox.DeptListSingleVmBox
import android.slc.user.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 *
 * @Description:
 * @Author: sunlunchang
 * @CreateDate: 2021/12/06 下午 2:55
 *
 */
class DeptListSingleDelegate : DeptListDelegate<DeptListSingleVmBox>() {
    override fun getAdapter(list: MutableList<SysDept>): BaseQuickAdapter<SysDept, BaseViewHolder> {
        return DeptSingleAdapter(list)
    }

    override fun initAdapterAndBaseEvent(): BaseQuickAdapter<SysDept, BaseViewHolder> {
        return super.initAdapterAndBaseEvent().apply {
            setOnItemChildClickListener { adapter, view, position ->
                when (view.id) {
                    R.id.radioButton -> {
                        vmBox.selectItem(position, adapter.getItem(position) as SysDept)
                    }
                }
            }
        }
    }
}